<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="fck" uri="/WEB-INF/FCKeditor.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=request.getContextPath() %>/css/Style.css" type="text/css" rel="stylesheet">
<title></title>
<script type="text/javascript">
	var tt_array = new Array();
	tt_array[0]="congye";
	tt_array[1]="zhuanchang";
	tt_array[2]="jianli";
	tt_array[3]="linian";
	tt_array[4]="zuopin";
	tt_array[5]="zhiwei";
	//tt_array[6]="name";
	var tmp_title ="";	
	var split_s ="songtai_split";
	function checkImage(){
			var img = document.getElementById("uploadimg").value;
			if(img.length<3){
				alert("只能上传 .BMP .JPG .JPEG .PNG .GIF 文件！");
				document.getElementById("sub_btn").disabled=true;
				return;
			}
			var regex=  /\.jpg$|\.jpeg$|\.gif$|\.png$/i;
			var len = img.lastIndexOf(".");
			img = img.substring(len).toLowerCase();
			if(!regex.test(img)){
				alert("只能上传 .BMP .JPG .JPEG .PNG .GIF 文件！");
				document.getElementById("sub_btn").disabled=true;
				return;
			}else{
				document.getElementById("sub_btn").disabled=false;
			}
		}
	function checkSubmit(){
	var type = document.getElementById("type").value;
		if(type=="designer"){
			var t_string = "{";
			for(var i = 0 ;i<tt_array.length;i++){
					var tt_string =document.getElementById(tt_array[i]+"").value;
					t_string+="\""+tt_array[i]+"\":" +"\""+tt_string+"\""+",";
			}
			t_string = t_string.substring(0, t_string.length-1);
			t_string += "}";
			document.getElementById("temp").value = t_string;
		}else if(type=="case"){
				var fenlei = document.getElementById("biaoqian").value;
				if(fenlei.length<1){
						alert("请填写分类标签！");
						return;
					}
				var f_string ='{"fenlei":"'+fenlei+'"}';
				document.getElementById("temp").value = f_string;
			}
		var title = document.getElementById("title").value;
		var content = document.getElementById("elseContent").value;
		var img = document.getElementById("uploadimg").value;
		if (title.length < 1) {
			alert("你还没有填写" + tmp_title + "！");
			return;
		}
		if (content.length < 1) {
			alert("你还没有填写说明！");
			return;
		}
		if (img.length < 3) {
			alert("只能上传 .BMP .JPG .JPEG .PNG .GIF 文件！");
			return;
		}
		var regex = /\.jpg$|\.jpeg$|\.gif$|\.png$/i;
		var len = img.lastIndexOf(".");
		img = img.substring(len).toLowerCase();
		if (!regex.test(img)) {
			alert("只能上传 .BMP .JPG .JPEG .PNG .GIF 文件！");
			return;
		} else {
			document.getElementById("c_from").submit();
		}
	}
</script>
</head>
<body>
	<table border="0" cellspacing="0" cellpadding="0" class="thead" width="100%">
	<tr><td style="padding:3px;">当前位置:上传图片</td></tr>
</table>
<form action="<%=request.getContextPath() %>/admin/addImage.htm" method="post" id="c_from" enctype="multipart/form-data">
<input type="hidden" name="type" id="type" value="<%=request.getParameter("type") %>"> 
<input type="hidden" name="nodeid" value="<%=request.getParameter("nodeid") %>"/>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
	<tr>
		<td width="10%">&nbsp;</td>
		<td>
		<table cellspacing="0" cellpadding="0" border="1"  class="Table1" align="center" width="100%">
			<tbody>
				<tr>
					<td></td>
					<td id="errormsg"><s:fielderror/><s:actionerror/> </td>
				</tr>
				<tr>
					<td height="25" align="right" width="20%">图片<span style="color:red;">*</span>：</td>
					<td width="80%"><input type="file" name="uploadimg" id="uploadimg" onchange="checkImage()"/></td>
				</tr>
				<tr>
					<td height="25" align="right"><span id="whattype">标题</span><span style="color:red;">*</span>：</td>
					<td><input type="text" name="title" maxlength="40" id="title" value="" /></td>
				</tr>
				<tr id="congye_tr" >
					<td height="25" align="right" width="20%">从业年限：</td>
					<td ><input type="text"  id="congye" /></td>
				</tr>
				<tr id="zhiwei_tr">
					<td height="25" align="right" width="20%">职位：</td>
					<td ><input type="text"  id="zhiwei" /></td>
				</tr>
				<tr id="zhuanchang_tr">
					<td height="25" align="right" width="20%">个人专长：</td>
					<td ><input type="text"  id="zhuanchang" /></td>
				</tr>
				<tr id="jianli_tr">
					<td height="25" align="right" width="20%">个人简历：</td>
					<td ><input type="text"  id="jianli" /></td>
				</tr>
				<tr id="linian_tr">
					<td height="25" align="right" width="20%">设计理念：</td>
					<td ><input type="text"  id="linian" /></td>
				</tr>
				<tr id="zuopin_tr" style="">
					<td height="25" align="right" width="20%">楼盘作品：</td>
					<td><input type="text"  id="zuopin" /></td>
				</tr>
				<tr id="name_tr" style="display: none">
					<td height="25" align="right" width="20%" ><span id="name_tip">显示位置</span>：</td>
					<td ><input type="text" name="name"  id="name" maxlength="4"/>&nbsp;&nbsp;<span id="tip">此处填入数字，数字越大，显示越靠前</span></td>
				</tr>
				<tr id="biaoqian_tr" style="">
					<td height="25" align="right" width="20%">标签分类：</td>
					<td><input type="text"  id="biaoqian" /></td>
				</tr>
				<script type="text/javascript">
					var t = document.getElementById("type").value;
					var show = "none";
					if(t=="designer"){
						tmp_title = "设计师";
						document.getElementById("name_tr").style.display="";
						show = "";
						}
					else{
						//document.getElementById("name_tr").style.display="none";
						tmp_title = "标题";
						show = "none";
						}
					for(var i = 0;i<tt_array.length;i++){
						document.getElementById(tt_array[i]+"_tr").style.display = show;
					}

					if(t=="case"){
						document.getElementById("name_tr").style.display="";
						document.getElementById("biaoqian_tr").style.display = "";
						document.getElementById("tip").innerHTML="输入任意值该案例将在首页展示，不输入则不会显示在首页";
						document.getElementById("name_tip").innerHTML="是否显示在首页";
						}else{
						document.getElementById("biaoqian_tr").style.display = "none";
						
					}
					document.getElementById("whattype").innerHTML=tmp_title;
				</script>
				<tr>
					<td height="25" align="right">说明<span style="color:red;">*</span>：</td>
					<td><fck:editor id="elseContent" height="300" width="100%" toolbarSet="Default" imageBrowserURL="../filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" linkBrowserURL="../filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" flashBrowserURL="../filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" imageUploadURL="../filemanager/upload/simpleuploader?Type=Image" linkUploadURL="../filemanager/upload/simpleuploader?Type=File" flashUploadURL="../filemanager/upload/simpleuploader?Type=Flash">
						</fck:editor>
					</td>
				</tr>
				<tr>
					<td height="25" colspan="2" align="center">
					<input type="button" onclick="checkSubmit();" value="确定" id="sub_btn" />
					<s:if test="method=='success'">
					<input type="button" onclick="window.location.href='<%=request.getContextPath() %>/admin/getSomeImage.htm?nodeid=${nodeid}&type=${type}'" value="返回查看"  />
					</s:if>
					</td>
				</tr>
			</tbody>
		</table>
		</td>
		<td width="10%">&nbsp;</td>
	</tr>
</table>
<input type="hidden" name="temp" id="temp" value=""/>
</form>
</body>
</html>